/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-05-18
*/
package com.rzico.order.entity;

import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * <pre>
 *   退货申请单明细项数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "wx_askfor_item")
public class AskforItem{
    @Id
    @ApiModelProperty(value = "" )
    protected Long id;

    @ApiModelProperty(value = "创建日期" )
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期" )
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "是否为赠品" )
    protected Boolean isGift;

    @ApiModelProperty(value = "商品名称" )
    protected String name;

    @ApiModelProperty(value = "单位" )
    protected String unit;

    @ApiModelProperty(value = "商品价格" )
    protected java.math.BigDecimal price;

    @ApiModelProperty(value = "数量" )
    protected java.math.BigDecimal quantity;

    @ApiModelProperty(value = "商品规格" )
    protected String spec;

    @ApiModelProperty(value = "商品缩略图" )
    protected String thumbnail;

    @ApiModelProperty(value = "类型 {0.产品,1:套餐,2:水票,3.压桶}" )
    protected Integer subType;

    @ApiModelProperty(value = "商品重量" )
    protected java.math.BigDecimal weight;

    @ApiModelProperty(value = "产品编号" )
    protected Long productId;

    @ApiModelProperty(value = "单品活动" )
    protected Long promotionId;

    @ApiModelProperty(value = "活动优惠金额" )
    protected java.math.BigDecimal discount;

    @ApiModelProperty(value = "券抵扣数量" )
    protected Long couponCodeQuantity;

    @ApiModelProperty(value = "使用的券" )
    protected Long couponCodeId;

    @ApiModelProperty(value = "结算价" )
    protected java.math.BigDecimal cost;

    @ApiModelProperty(value = "条码/货号" )
    protected String sn;

    @ApiModelProperty(value = "运单号")
    protected String trackingNo;

    @ApiModelProperty(value = "申请单" )
    protected Long askforId;


    @ApiModelProperty(value = "商品金额")
    public BigDecimal getAmount(){
        if (getQuantity()==null) {
            setQuantity(BigDecimal.ZERO);
        }
        if (getPrice()==null) {
            setPrice(BigDecimal.ZERO);
        }
        return this.getPrice().multiply(this.getQuantity()).setScale(2,BigDecimal.ROUND_HALF_DOWN);
    }

    @ApiModelProperty(value = "实退金额")
    public BigDecimal getSubTotal() {
        if (getQuantity()==null) {
            setQuantity(BigDecimal.ZERO);
        }
        if (getPrice()==null) {
            setPrice(BigDecimal.ZERO);
        }
        return getAmount().subtract(getDiscount());
    }

    public void setAmount(BigDecimal value) {

    }

    public void setSubTotal(BigDecimal subTotal){

    }

    public BigDecimal calculateSubCost() {
        return getQuantity().multiply(getCost()).setScale(2,BigDecimal.ROUND_HALF_DOWN);
    }

    @ApiModelProperty(value = "收货人信息")
    @Transient
    protected String phone;

    @ApiModelProperty(value = "所在地" )
    @Transient
    protected String areaName;

    @ApiModelProperty(value = "收货地址" )
    @Transient
    protected String address;

    @ApiModelProperty(value = "收货人" )
    @Transient
    protected String consignee;

}
